const RecommendListModel = require('../db/models/recommend_list');
//修改

class RecommendListServer { //修改
  //修改
  async addRecomList (data) {
    //检查cid是否存在 check cid is existed
    const userId = data.userId; //修改
    //修改
    const result = await RecommendListModel.findOne({where: { userId }});
    //判断 check
    if (result) { 
      //更新 update  //修改
      return await RecommendListModel.update(data, {where: { userId }})
    }else {
      //创建 create
      return await RecommendListModel.create(data);
    }
  }
  
  //查询
  async findRecomListById (userId) {
    return await RecommendListModel.findOne({where: { userId }});
  }
}
//修改
module.exports = new RecommendListServer();